package com.mm.dds.datasource;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by YHYR on 2017-12-25
 */

public class DataSourceContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static List<String> dataSourceIds = new ArrayList<String>();

    public static synchronized void setDBType(String dbType){

        contextHolder.set(dbType);
    }

    public static String getDBType(){

        return contextHolder.get();
    }

    public static void clearDBType(){

        contextHolder.remove();
        System.out.println("db-clear");
    }
    //判断当前数据源是否存在
    public static boolean isContainsDataSource(String dataSourceId) {

        return dataSourceIds.contains(dataSourceId);
    }
}
